package com.feng.stateAnalysis
{
	import com.feng.data.StateData;
	import com.feng.debug.logger;
	import com.feng.utils.ChallengeCompute;

	/**
	 * 三人模式下形势分析
	 * @author 风之守望者
	 * 2013-3-30
	 */
	public class ThreeAnalysis
	{
		/**
		 * 分析三人模式下形势
		 */
		public function analysis():void
		{
			logger("分析三人模式下形势");

			//找出较强的与较弱的
			enemyChallengeValue = ChallengeCompute.challenge(enemyList[0], enemyList[1]);

			//较强的敌人
			powerfulEnemy = enemyChallengeValue > 0 ? enemyList[0] : enemyList[1];
			//较弱的敌人
			punyEnemy = enemyChallengeValue > 0 ? enemyList[1] : enemyList[0];

			//我与较强的单挑结果
			powerfulChallengeValue = ChallengeCompute.challenge(me, powerfulEnemy);

			//我与较弱的单挑结果
			var punyfulChallengeValue:Number = ChallengeCompute.challenge(me, punyEnemy);

			/***************** 判断处境，选择对策 ***************/
			logger("【实力情况】→ →" + "enemyChallengeValue:" + enemyChallengeValue + ",powerfulChallengeValue:" + powerfulChallengeValue + ",punyfulChallengeValue:" + punyfulChallengeValue);
			//处于最强
			if (powerfulChallengeValue > 0 && punyfulChallengeValue > 0)
			{
				myState = FORTISSIMO;
			}
			//处于最弱
			else if (powerfulChallengeValue < 0 && punyfulChallengeValue < 0)
			{
				myState = WEAKEST;
			}
			//处于 比强的弱，比弱的强
			else if (powerfulChallengeValue < 0 && punyfulChallengeValue >= 0)
			{
				myState = MIDDLE;
			}
			//处于 比强的强，比弱的弱
			else
			{
				logger("牵制(比强还强，比弱还弱) 【神奇啊，居然还会有这种情况，石头剪刀布！】");
				myState = CONTAIN;
			}
		}

		/******************************* 定义状态 *************************************/
		/** 最强 */
		public static const FORTISSIMO:String = "最强";

		/** 最弱 */
		public static const WEAKEST:String = "最弱";

		/** 中间(比强的弱，比弱的强) */
		public static const MIDDLE:String = "中间(比强的弱，比弱的强)";

		/** 牵制(比强还强，比弱还弱) */
		public static const CONTAIN:String = "牵制(比强还强，比弱还弱)";

		/**********************************************************************/
		/** 较强的敌人 */
		public var powerfulEnemy:Object;

		/** 较弱的敌人 */
		public var punyEnemy:Object;

		/** 我的处境 */
		public var myState:String = WEAKEST;

		/** 找出较强的与较弱的 */
		public var enemyChallengeValue:Number;

		/** 我与较强的单挑结果 */
		public var powerfulChallengeValue:Number;

		/** 我与较弱的单挑结果 */
		public var punyfulChallengeValue:Number;

		private var stateData:StateData;

		public function ThreeAnalysis(stateData:StateData)
		{
			this.stateData = stateData;
		}

		private function get enemyList():Array
		{
			return stateData.enemyList;
		}

		private function get me():Object
		{
			return stateData.me;
		}
	}
}
